﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using egypt.Logic.Data;

namespace egypt.Web.Admin
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Login1.Authenticate += new AuthenticateEventHandler(Login1_Authenticate);
        }


        void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            DataAdapter da = new DataAdapter(System.Configuration.ConfigurationManager.ConnectionStrings["egypt"].ConnectionString);
            if (da.Login(this.Login1.UserName, this.Login1.Password))
            {
                e.Authenticated = true;
                FormsAuthentication.RedirectFromLoginPage(this.Login1.UserName, true);
                if (Page.Request.QueryString["ReturnUrl"] != null)
                    Response.Redirect(Page.Request.QueryString["ReturnUrl"]);
                else
                    Response.Redirect("addnews.aspx");
            }
        }

    }
}
